// 云函数模板
// 部署：在 cloud-functions/server_now_time 文件夹右击选择 “上传并部署”

const cloud = require('wx-server-sdk')

// 初始化 cloud
cloud.init({
  env: 'yxzclassroomquery-2e2n5pc39df1a0'
})

/**
 * 这个示例将经自动鉴权过的小程序用户 openid 返回给小程序端
 * 
 * event 参数包含小程序端调用传入的 data
 * 
 */
const db = cloud.database();

exports.main = async (event, context) => {

  // 获取当前的时间
  var date = new Date();
  var n = date.getTime();
  var year = date.getFullYear();
  var month = date.getMonth() + 1;
  var day = date.getDate();
  var hour = date.getHours();
  var minute = date.getMinutes();
  var second = date.getSeconds();

  return {
    date: date,
    n: n,
    year: year,
    month: month,
    day: day,
    hour: hour,
    minute: minute,
    second: second
  }
}

